#coding:utf8

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import time

from flask import Blueprint
from flask import jsonify

from libapi import ApiDoc, ApiNode,cpts

bp_v1 = Blueprint("user", __name__, url_prefix="/v2/user")


@bp_v1.route("<int:userId>", endpoint="update_user", methods=["POST","GET"])
@ApiDoc.api_doc(summary="update user account",
                description="update user account",
                tag="User",
                # resp=cpts.refs['OmConfig'],
                errors=[(403, '权限限制'), (404, '路径错误')],
                name=ApiNode("str", True),
                ip=ApiNode("str", False, limit=['1', '2', '3', '4']),
                address=ApiNode("str", True),
                userId=ApiNode("basestring", True, op_in=ApiDoc.OP_PATH, limit=(20, 40)),
                limit=ApiNode("int", False, op_in=ApiDoc.OP_BODY),
                offset=ApiNode("int", False, op_in=ApiDoc.OP_BODY)
                )
def update_user(userId):
    """Example endpoint returning a list of colors by palette
    This is using docstrings for specifications.
    ---
    parameters:
      - name: palette
        in: path
        type: string
        enum: ['all', 'rgb', 'cmyk']
        required: true
        default: all
    definitions:
      Palette:
        type: object
        properties:
          palette_name:
            type: array
            items:
              $ref: '#/definitions/Color'
      Color:
        type: string
    responses:
      200:
        description: A list of colors (may be filtered by palette)
        schema:
          $ref: '#/definitions/Palette'
        examples:
          rgb: ['red', 'green', 'blue']
    """
    response_map = {
        "errorCode": 200,
        "message": "成功",
        "serverTime": int(round(time.time() * 1000)),
        "data": [],
    }

    return jsonify(response_map)
